<script>
_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
if(h<_rate*1206){
	h=_rate*1206;
}

 var _video = document.getElementById("thev1");
var _mbgFlag=true;
var _usermbgFlag=true;
var _mbg=document.getElementById("mbg");
$(function(){
  
	$('.container').width(sWidth).height(h);
    $('.p1-yin').width(_rate*83).height(_rate*83).css({"top":_rate*30, "right":_rate*30});

   
    $('.p1-logo').css({"top":_rate*10});
    $('.p1-t3').css({"top":_rate*120});
    $('.p1-t2').height(_rate*390).css({"top":_rate*544});
    $('#p1-name').width(_rate*476).height(_rate*67).css({"top":_rate*66, "left":_rate*140, "line-height":_rate*67+'px'});
    $('#p1-school, .p1-school-txt').width(_rate*476).height(_rate*67).css({"top":_rate*166, "left":_rate*140, "line-height":_rate*67+'px'});

    $('.p1-start').width(_rate*400).height(_rate*110).css({"top":_rate*262, "left":_rate*170});

    $('.p2-t2').height(_rate*1095).css({"top":_rate*74});
    $('.p2-t3').width(_rate*267).css({"top":_rate*6, "left":_rate*404});
    $('.p2-txt').height(_rate*100).css({"top":_rate*174, "line-height":_rate*100+'px'});
    $('.p2-jrxy').width(_rate*430).height(_rate*120).css({"top":_rate*970, "left":_rate*160});
    $('.minh-t1, .view-t1').width(_rate*153).height(_rate*341).css({"top":_rate*102, "right":0});

    var _tmpH=h - _rate*30;
    $('.minh-txt').height(_tmpH);
    $('.msg-tu').width(_rate*650);
    $('.mhang-tu').width(_rate*543);
   
    $('.minh-t2').css({"bottom":0});
    $('.minh-arr').width(_rate*161).css({"left":_rate*294});

    $('.map-t1').width(_rate*168).css({"top":_rate*268, "left":_rate*238});
    $('.map-t2').width(_rate*183).css({"top":_rate*522, "left":0});
    $('.map-t3').width(_rate*163).css({"top":_rate*556, "left":_rate*272});
    
    $('.map-t4').width(_rate*164).css({"top":_rate*776, "left":_rate*166});
    $('.map-t5').width(_rate*204).css({"top":_rate*876, "left":0});
    $('.map-t6').width(_rate*330).css({"top":_rate*932, "left":0});

    $('.map-t7').width(_rate*214).css({"top":_rate*828, "right":0});
    $('.map-t8').width(_rate*203).css({"top":_rate*878, "left":_rate*354});
    $('.map-t9').width(_rate*313).css({"top":_rate*1060, "left":_rate*251});
    $('.map-z1').css({"bottom":_rate*36});
    
    $('.end-t2').height(_rate*1052).css({"top":_rate*106});
    $('.end-txt').height(_rate*100).css({"top":_rate*236, "line-height":_rate*100+'px'});
    $('.end-back').width(_rate*430).height(_rate*120).css({"top":_rate*940, "left":_rate*160});
     
     $('.kdzx-t1, .yws-t1').css({"top":0});
     $('.kdzx-t2, .yws-t2').css({"top":_rate*250});
     $('.kdzx-t3, .yws-t3').css({"top":_rate*488});
     
     $('.sushe-t1, .stang-t1, .xyuan-t1').width(_rate*102).css({"top":_rate*446, "right":0});
     $('.stang .long-tu').width(_rate*544);
      $('.xyuan-txt .long-tu').width(_rate*531);
     _tmpH=h - _rate*10;
     $('.stang-txt').height(_tmpH);

     _tmpH=h - _rate*140;
     $('.sushe-txt').height(_tmpH);
     _tmpH=h - _rate*40;
     $('.xyuan-txt').height(_tmpH);
 

     $('.caiz-t1').css({"top":0});
     $('.caiz-t2').css({"top":_rate*210});
     $('.caiz-t3').css({"top":_rate*374});
     $('.xszx-t1').css({"top":0});
     $('.xszx-t2').css({"top":_rate*218});
     $('.xszx-t3').css({"top":_rate*496});
     $('.jxlou-t1').css({"top":0});
     $('.jxlou-t2').css({"top":_rate*184});
     $('.jxlou-t3').css({"top":_rate*506});

     $('.hlgc-kv, .thevideo').height(_rate*422).css({"top":_rate*480});
     $('.hlgc-play').width(_rate*200).css({"top":_rate*111, "left":_rate*275});
     
    
    if(h > _rate*1206){
        $(".p1-bg").attr("src","<?php echo $cdnUrl ?>img/p1-x.jpg");
         var _cha=h - _rate*1466;
        if(_cha < 0){
          $('.p-b').css({"top":_cha});
        }
        $(".p2-bg").height(h);
        _cha=h - _rate*1300;
        if (_cha< 0) {_cha=0;}
        $('.thebg').css({"top":_cha/2});
        
    }

    if(h < _rate*1380){
        _cha=h - _rate*1350;
        $('.themap').css({"top":_cha});
        
    }
    
    $(".p1").fadeIn();

     wx.config({
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'showMenuItems', 'hideMenuItems']
    });
    var _title='上海电机学院';
    var _desc='上海电机学院2021级新生报道掌上攻略';
    var _link='http://sdju.mei94.com/';
    var _imgUrl='http://sdju.mei94.com/img/64.jpg?v=1';
      wx.ready(function () {
        wx.updateAppMessageShareData({
            title: _title, 
            desc: _desc, 
            link: _link, 
            imgUrl: _imgUrl,success: function () {}
          });
         wx.updateTimelineShareData({
                title: _desc, 
                link: _link, 
                imgUrl: _imgUrl, success: function () {}});
      });

    _mbg.play();
    document.addEventListener("WeixinJSBridgeReady", function () { _mbg.play();}, false);

    function _loadMh(){
        var _url=$(".minh-data-url").attr("data-url");
        $(".minh-data-url").attr("src",_url);
    }
    $( "#p1-school").change(function() {
	   if('' == $("#p1-school").val()){
           $(".p1-school-txt").html("请选择学院");
           $("#p1-school, .p1-school-txt").addClass("se-col");
	   }else{
           $("#p1-school, .p1-school-txt").removeClass("se-col");
           console.log($("#p1-school").val());
           var _schoolTxt={
            1:'材料学院',
            2:'电气学院',
            3:'电子信息学院',
            4:'机械学院',
            5:'凯劳学院',
            6:'外国语学院',
            21:'商学院',
            22:'设计与艺术学院',
            23:'高职学院'

           };

           $(".p1-school-txt").html(_schoolTxt[$("#p1-school").val()]);
           if($("#p1-school").val() > 20){
             _loadMh();
           }
	   }
	});


	 var _canPlay=true;
	  $(".hlgc-kv").click(function(){
		if(false == _canPlay){return;}
		_canPlay=false;
		$(".hlgc-kv").fadeOut();
		$("#thev1").show();
		_video.play();
	    window.setTimeout(function(){
			  _canPlay=true;
	          }, 200);
        $(".p1-yin").removeClass("gorotate").attr("src","./img/yin2.png");
        _mbgFlag=false;
        _mbg.pause();

	  });

	  window.setTimeout(function(){
		  _video.addEventListener('ended',function(){
			  $(".thevideo").hide();
		      $(".hlgc-kv").fadeIn();
	      });
	  }, 500);
      
     
     var _xqu='lg';
     $( ".p1-start").click(function(){
        var _name=$('#p1-name').val();    
     	var _school=$("#p1-school").val();
    	if('' == _name){
    		_popMsg("请输入姓名");
    		return;
    	}
    	if('' == _school){
    		_popMsg("请选择学院");
    		return;
    	}
    	$(".p2-txt, .end-txt").html('<span>Hi，</span>'+_name);
    	$.post("api/?c=gets", {name:_name,school:_school}, function(data){
    		  console.log(data);
    		  if('y' == data.s){
                  _xqu=data.x;
    		  	  $(".p1").fadeOut();
                  $(".p2").fadeIn();
                  
                     if ('lg' == data.x){
                         
                     }else{
                        _loadMh();
                     }
    		  }
    	}, "json"); 
console.log(_school);
    	//$(".p1").hide();

	    console.log(_school);
	});
    
    $('.p2-jrxy').click(function(){
         if ('lg' == _xqu){
            $(".map").fadeIn();
         }else{
            $(".minhang").fadeIn();
         }
         $(".p2").fadeOut();
    });
     

    $( ".minh-t1").click(function(){
    	$(".minhang").fadeOut();
    	$(".end").fadeIn();
    });
    $( ".end-back").click(function(){
    	$(".end").fadeOut();
    	$(".p1").fadeIn();
    });

    function _popMsg(msg){
		$(".weui-msg").html(msg);
        $(".js_dialog").show();
	}
    $(".weui-btn").click(function(){
        $(".js_dialog").hide();
	});

    var _mapClick=true;
    var _mapLog=[];
	$(".map-t1, .map-t2, .map-t3, .map-t4, .map-t5, .map-t6, .map-t7, .map-t8, .map-t9").click(function(){
		if(false == _mapClick){return;}
		_mapClick=false;
		var _id=$(this).attr("data-id");
        var _hasId=false;
        for (var i =0; i < _mapLog.length;i++) {
            if(_mapLog[i] == _id){
                 _hasId=true;
            }
        }
        if(false == _hasId){
            _mapLog.push(_id);
        }
		console.log(_id);
		$("."+_id).fadeIn();
		$(".map").fadeOut();
		window.setTimeout(function(){_mapClick=true;}, 200);
        console.log(_mapLog);
	});

	$(".view-t1").click(function(){
        if(false == _mapClick){return;}
        _mapClick=false;
        window.setTimeout(function(){_mapClick=true;}, 200);
        var _id=$(this).attr("data-id");
        if('end'  == _id){
            console.log(_mapLog);
             
            console.log(_mapLog.length);
            if (_mapLog.length > 8) {
                $(".map").fadeOut();
                $(".end").fadeIn();
            }else{
                _popMsg("要浏览完全部坐标才能进行下一步哦");
            }
        	return false;
        }
        if('hlgc'  == _id){
           _video.pause();
           if(_usermbgFlag){
            $(".p1-yin").addClass("gorotate").attr("src","./img/yin.png");
            _mbgFlag=true;
            _mbg.play();
           }
           
        }
		console.log(_id);
		$("."+_id).fadeOut();
		$(".map").fadeIn();
	});
    
    $(".p1-yin").addClass("gorotate");
	
    $(".p1-yin").click(function(){
         if(true == _mbgFlag){
			$(".p1-yin").removeClass("gorotate").attr("src","./img/yin2.png");
			_mbgFlag=false;
            _usermbgFlag=false;
			_mbg.pause();
	    }else{
	    	$(".p1-yin").addClass("gorotate").attr("src","./img/yin.png");
	    	_mbgFlag=true;
            _usermbgFlag=true;
	    	_mbg.play();	
		}
    });   
      
});
</script>